package exception;
import java.util.InputMismatchException;
import java.util.Scanner;

public class Divide2 {
    public static void main(String[] args) {
        int a, b, c;
        Scanner in = new Scanner(System.in);//实例化Scanner对象
        System.out.println("请输入a、b值：");//用户提示
        try {
            a = in.nextInt();//输入一个整数存入变量a
            b = in.nextInt();//输入一个整数存入变量b
            c = a / b;
            System.out.println("商为：" + c);
        } catch (InputMismatchException e) {
            e.printStackTrace();
            System.out.println("您只能输入数字！");
        }
        catch(ArithmeticException e){
            System.out.println("除数不能为零！");
        }



    }
}
